// 删除这行导入
// import { createApp } from 'vue'
import { ViteSSG } from "vite-ssg";
import { createWebHashHistory } from "vue-router";
import App from "./App.vue";
import i18n, { loadLocaleFromStorage } from "./locales";

// Vuetify
import "vuetify/styles";
import "@mdi/font/css/materialdesignicons.css";
import { createVuetify } from "vuetify";
import * as components from "vuetify/components";
import * as directives from "vuetify/directives";
import { setupLayouts } from "virtual:generated-layouts";
import generatedRoutes from "virtual:generated-pages";

// 路由配置
const routes = setupLayouts(generatedRoutes);

// 创建 Vuetify 实例
const vuetify = createVuetify({
  components,
  directives,
  theme: {
    defaultTheme: "light",
    themes: {
      light: {
        colors: {
          primary: "#1867C0",
          secondary: "#5CBBF6",
        },
      },
    },
  },
});

// 恢复保存的语言设置
loadLocaleFromStorage();

// ViteSSG配置
// https://github.com/antfu/vite-ssg
export const createApp = ViteSSG(
  App,
  { 
    routes, 
    base: import.meta.env.BASE_URL,
    // 移除 routerOptions，使用默认的 history 模式
  },
  (ctx) => {
    ctx.app.use(vuetify);
    ctx.app.use(i18n);
  }
)
